# -*- coding:utf-8 -*-
import random
from 算法.time_cal import cal_time
# 操作复杂度O(n*n)

def findSmallest(arr):
    smallest = arr[0]
    smallest_index = 0
    for i in range(1, len(arr)):
        if arr[i] < smallest:
            smallest = arr[i]
            smallest_index = i
    return smallest_index

@cal_time
def selectionSort(arr):
    newArr = []
    for i in range(len(arr)):
        smallest = findSmallest(arr)
        newArr.append(arr.pop(smallest))
    return newArr

l = [x for x in range(1000)]

random.shuffle(l)
print(
    l
)
print(selectionSort(l))